package cn.com.api.controller;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pingplusplus.Pingpp;
import com.pingplusplus.model.Charge;
import com.pingplusplus.model.Event;
import com.pingplusplus.model.Webhooks;

import cn.com.api.entity.ApiDingDan;
import cn.com.api.mapper.ApiDingDanMapper;
import cn.com.api.requestpage.PaytypeConfirmPage;
import cn.com.api.service.ApiOrderService;
import cn.com.api.service.ApiPaymentService;
import cn.com.api.service.CheckService;
import cn.com.util.*;
import cn.com.pingpp.*;

@Controller
@RequestMapping(Utils.SYS_API + "payment/")
public class ApiPaymentController {
	@Autowired
	private CheckService checkService;
	@Autowired
	private ApiPaymentService apiPaymentService;
	@Autowired
	private ApiDingDanMapper apiDingDanMapper;
	@Autowired
	private ApiOrderService apiOrderService;

	private static Logger logger = Logger.getLogger(ApiPaymentController.class);

	/**
	 * 支付方式确认，之后支付回调更新数据 是否使用余额支付，余额支付是否充足
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@Transactional
	@RequestMapping(value = "confirmInfo")
	public void confirmPaytype(PaytypeConfirmPage paytypeConfirmPage, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		String u_id = paytypeConfirmPage.getU_id();
		String token = paytypeConfirmPage.getToken();
		try {
			// 校验数据
			if (checkService.checkToken(u_id, token, map)
					&& checkService.checkPaytypeConfirmPage(paytypeConfirmPage, map)) {
				// 支付时，校验erp库存是否充足--在checkPaytypeConfirmPage里校验
				apiPaymentService.confirmPaytype(paytypeConfirmPage, map);
			}
		} catch (Exception e) {
			logger.error(Util.getStackTraceAsString(e));
			e.printStackTrace();
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "系统异常！");
		}
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(JsonUtil.object2json(map));
		out.close();
	}

	/**
	 * 支付宝回调函数 aliPay
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@Transactional
	@RequestMapping(value = "aliPay")
	public void aliPay(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			// 获取支付宝的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)//
			// 商户订单号

			String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");

			// 支付宝交易号

			String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"), "UTF-8");

			// 交易状态
			String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"), "UTF-8");

			// 获取支付宝的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)//
			logger.error("---------支付宝回调开始----------");
			logger.error("---------支付宝验证开始----------");

			Map<String, String> params = new HashMap<String, String>();
			params.put("out_trade_no", out_trade_no);
			params.put("trade_no", trade_no);
			params.put("trade_status", trade_status);
			if (checkService.checkParams(params, map)) {// 参数校验成功
				if ("TRADE_SUCCESS".equals(trade_status)) {// 支付成功
					logger.error("---------参数校验成功----------");
					ApiDingDan dingDan = apiDingDanMapper.searchDingDanByTitleId(out_trade_no);
					// 判断订单支付状态
					if (dingDan != null && 0 == dingDan.getZi_status()) {// 0-待支付
																			// 1-支付成功---0的话支付成功
						if (0 == dingDan.getOrderType() || 4 == dingDan.getOrderType()) {// 购物订单--1元购
							apiPaymentService.payStatusWriteBack(params, map);
							logger.error("---------支付宝--购物订单回调 ：" + out_trade_no + "-" + trade_no + "-" + trade_status
									+ "----------");
						} else {// 充值订单
							apiPaymentService.chargeWriteBack(params, map);
							logger.error("---------支付宝--充值订单回调--" + out_trade_no + "-" + trade_no + "-" + trade_status
									+ "--------");
						}
					}
				}

			}

			System.out.println("out_trade_no-" + out_trade_no);
			System.out.println("trade_no-" + trade_no);
			System.out.println("trade_status-" + trade_status);
			// map.put(Utils.RESULT, "0000");
			// map.put(Utils.MESSAGE, "支付宝返回数据！");
			map.put("out_trade_no", out_trade_no);
			map.put("trade_no", trade_no);
			map.put("trade_status", trade_status);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, Utils.getMessage(request, "API_ERROR_UNKNOW", null));
		}
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(JsonUtil.object2json(map));
		out.close();
	}

	/**
	 * 微信回调函数 weChatPay
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@Transactional
	@RequestMapping(value = "weChatPay")
	public void weChatPay(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			// 获取微信的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)//

			Map<String, String> paramDate = null; // MessageUtil.parseXmlMessage(request);
			/** 把所有的参数打印看看 */
			System.out.println("通过Map.entrySet遍历key和value");
			for (Map.Entry<String, String> entry : paramDate.entrySet()) {
				System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
				logger.error("key= " + entry.getKey() + " and value= " + entry.getValue());
			}
			// 交易状态
			String return_code = paramDate.get("return_code");

			// 商户订单号
			String out_trade_no = paramDate.get("out_trade_no");

			// 微信交易号 transaction_id
			String trade_no = paramDate.get("transaction_id");

			// 获取支付宝的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)//
			logger.error("---------微信回调开始----------");
			logger.error("---------微信验证开始----------");

			Map<String, String> params = new HashMap<String, String>();
			params.put("out_trade_no", out_trade_no);
			params.put("trade_no", trade_no);
			params.put("trade_status", return_code);
			if (checkService.checkParams(params, map)) {// 参数校验成功
				if ("SUCCESS".equals(return_code)) {// 支付成功
					logger.error("---------参数校验成功----------");
					ApiDingDan dingDan = apiDingDanMapper.searchDingDanByTitleId(out_trade_no);
					// 判断订单支付状态
					if (dingDan != null && 0 == dingDan.getZi_status()) {// 0-待支付
																			// 1-支付成功---0的话支付成功
						params.put("trade_status", "TRADE_SUCCESS");
						if (0 == dingDan.getOrderType() || 4 == dingDan.getOrderType()) {// 购物订单
																							// 1元购
							apiPaymentService.payStatusWriteBack(params, map);
							logger.error("---------微信 --购物订单回调 ：" + out_trade_no + "-" + trade_no + "-" + return_code
									+ "----------");
						} else {// 充值订单
							apiPaymentService.chargeWriteBack(params, map);
							logger.error("---------微信 --充值订单回调--" + out_trade_no + "-" + trade_no + "-" + return_code
									+ "--------");
						}
					}
				}

			} else {
				map.put(Utils.RESULT, Utils.RESULT_RC_CHECK_FAIL);
				map.put(Utils.MESSAGE, "回调失败！");
			}

			System.out.println("out_trade_no-" + out_trade_no);
			System.out.println("trade_no-" + trade_no);
			System.out.println("trade_status-" + return_code);
			map.put("out_trade_no", out_trade_no);
			map.put("trade_no", trade_no);
			map.put("trade_status", return_code);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "回调异常！");
		}
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(JsonUtil.object2json(map));
		out.close();
	}

	/**
	 * 充值中心-充值确认
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@Transactional
	@RequestMapping(value = "charge")
	public void chargeMoney(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();

		try {
			String u_id = request.getParameter("u_id");
			String token = request.getParameter("token");
			String money = request.getParameter("money");
			String payType = request.getParameter("payType");
			String city_id = request.getParameter("city_id");
			Map<String, String> parammap = new HashMap<String, String>();
			parammap.put("u_id", u_id);
			parammap.put("token", token);
			parammap.put("money", money);
			parammap.put("payType", payType);
			parammap.put("city_id", city_id);
			System.out.println("u_id-" + u_id);
			System.out.println("money-" + money);
			System.out.println("payType-" + payType);
			if (checkService.checkToken(u_id, token, map) && checkService.checkChargeMoney(parammap, map)) {
				apiPaymentService.confirmChargeType(parammap, map);
				logger.error("--------------充值中心-账户充值----------------");
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("账户充值异常：" + Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "系统异常！");
		}

		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(JsonUtil.object2json(map));
		out.close();
	}

	/**
	 * 支付宝回调函数 aliPay-----充值中心回调暂不使用，订单支付，充值支付使用同一个回调函数
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@Transactional
	@RequestMapping(value = "aliPayChargeBack")
	public void aliPayChargeBack(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			// 获取支付宝的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)//
			// 商户订单号

			String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");

			// 支付宝交易号

			String trade_no = new String(request.getParameter("trade_no").getBytes("ISO-8859-1"), "UTF-8");

			// 交易状态
			String trade_status = new String(request.getParameter("trade_status").getBytes("ISO-8859-1"), "UTF-8");

			// 获取支付宝的通知返回参数，可参考技术文档中页面跳转同步通知参数列表(以上仅供参考)//

			System.out.println("支付宝验证开始——————————");
			Map<String, String> params = new HashMap<String, String>();
			params.put("out_trade_no", out_trade_no);
			params.put("trade_no", trade_no);
			params.put("trade_status", trade_status);
			if (checkService.checkParams(params, map)) {// 参数校验成功
				apiPaymentService.chargeWriteBack(params, map);
			}

			System.out.println("out_trade_no-" + out_trade_no);
			System.out.println("trade_no-" + trade_no);
			System.out.println("trade_status-" + trade_status);

			map.put("out_trade_no", out_trade_no);
			map.put("trade_no", trade_no);
			map.put("trade_status", trade_status);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "系统异常！");
		}
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(JsonUtil.object2json(map));
		out.close();
	}

	/**
	 * 查看充值记录-消费记录
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "getChargeRecord")
	public void getChargeRecord(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();

		try {
			String u_id = request.getParameter("u_id");
			String token = request.getParameter("token");
			String pageCount = request.getParameter("pageCount");
			String type = request.getParameter("type");// 类型：1-充值记录 2-消费记录
			Map<String, String> params = new HashMap<String, String>();
			params.put("u_id", u_id);
			params.put("token", token);
			params.put("pageCount", pageCount);
			params.put("type", type);
			if (checkService.checkToken(u_id, token, map) && checkService.checkParams(params, map)) {
				apiOrderService.getChargeCondition(params, map);
			}

		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "系统异常！");
		}

		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(JsonUtil.object2json(map));
		out.close();
	}

	/**
	 * 支付--订单生成之后再单独-单个订单支付
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "payOrderInit")
	public void payOrderInit(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();

		try {// checkService.checkToken(u_id,token,map) &&
			String u_id = request.getParameter("u_id");
			String titles = request.getParameter("titles");
			String token = request.getParameter("token");
			Map<String, String> params = new HashMap<String, String>();
			params.put("u_id", u_id);
			params.put("titles", titles);
			params.put("token", token);
			if (checkService.checkToken(u_id, token, map) && checkService.checkParams(params, map)) {
				apiPaymentService.payOrderInit(params, map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "系统异常！");
		}

		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(JsonUtil.object2json(map));
		out.close();
	}

	/**
	 * 余额支付
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "balancePayment")
	public void balancePayment(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();

		try {
			String user_id = request.getParameter("user_id");
			String token = request.getParameter("token");
			String order_no = request.getParameter("order_no");
			String password = request.getParameter("password");
			String amount = request.getParameter("amount");
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("user_id", user_id);
			params.put("serialflagno", order_no);
			params.put("amount", amount);
			params.put("password", password);
			if (checkService.checkToken(user_id, token, map)) {
				map.clear();
				apiPaymentService.balancePayment(params, map);
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "系统异常！");
		}
		JsonUtil.printJson(response, JsonUtil.object2json(map));
	}

	/**
	 * Ping++ 获取支付凭证(chareg对象)
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@Transactional
	@RequestMapping(value = "getPingppCharge")
	@ResponseBody
	public Map<String, Object> getPingppCharge(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			String user_id = request.getParameter("user_id");
			String token = request.getParameter("token");
			String order_no = request.getParameter("order_no");
			Integer amount = Integer.valueOf(request.getParameter("amount"));
			String channel = request.getParameter("channel");
			String client_ip = request.getParameter("client_ip");
			String subject = request.getParameter("subject");
			String body = request.getParameter("order_desc");
			String open_id = request.getParameter("open_id");

			if (checkService.checkToken(user_id, token, map)) {
				if (PingppConfig.pingChanelmap.containsKey(channel)) {
					// 加入订单金额验证逻辑
					Pingpp.apiKey = PingppConfig.apiKey;
					Map<String, Object> chargeParams = new HashMap<String, Object>();
					Map<String, String> app = new HashMap<String, String>();
					Map<String, String> extra = new HashMap<String, String>();

					switch (channel) {
					case "alipay":
						chargeParams.put("order_no", order_no);
						chargeParams.put("amount", amount);
						app.put("id", PingppConfig.appId);
						chargeParams.put("app", app);
						chargeParams.put("channel", "alipay");
						chargeParams.put("currency", "cny");
						chargeParams.put("client_ip", client_ip);
						chargeParams.put("subject", subject);
						chargeParams.put("body", body);
						break;
					case "wx":
						chargeParams.put("order_no", order_no);
						chargeParams.put("amount", amount);
						app.put("id", PingppConfig.appId);
						chargeParams.put("app", app);
						chargeParams.put("channel", "wx");
						chargeParams.put("currency", "cny");
						chargeParams.put("client_ip", client_ip);
						chargeParams.put("subject", subject);
						chargeParams.put("body", body);
						break;
					case "alipay_pc_direct":
						chargeParams.put("order_no", order_no);
						chargeParams.put("amount", amount);
						app.put("id", PingppConfig.appId);
						chargeParams.put("app", app);
						chargeParams.put("channel", "alipay_pc_direct");
						chargeParams.put("currency", "cny");
						chargeParams.put("client_ip", client_ip);
						chargeParams.put("subject", subject);
						chargeParams.put("body", body);
						// Map<String, String> extra = new HashMap<String,
						// String>();
						extra.clear();
						extra.put("success_url", "http://www.sm1168.com/B2B4Shoumei/api/payment/pingppChargeCallBack");
						chargeParams.put("extra", extra);
						break;
					case "wx_pub":
						chargeParams.put("order_no", order_no);
						chargeParams.put("amount", amount);
						app.put("id", PingppConfig.appId);
						chargeParams.put("app", app);
						chargeParams.put("channel", "wx_pub");
						chargeParams.put("currency", "cny");
						chargeParams.put("client_ip", client_ip);
						chargeParams.put("subject", subject);
						chargeParams.put("body", body);
						// Map<String, String> extra = new HashMap<String,
						// String>();
						extra.clear();
						extra.put("open_id", open_id);
						chargeParams.put("extra", extra);
						break;
					default:
						break;
					}
					Charge charge = Charge.create(chargeParams);
					map.put(Utils.RESULT, Utils.RESULT_RC_SUCCESS);
					map.put(Utils.MESSAGE, "操作成功");
					map.put(Utils.DATAS, charge);
				} else {
					map.put(Utils.RESULT, Utils.RESULT_RC_PARAMTER_ERROR);
					map.put(Utils.MESSAGE, "支付渠道错误！");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
			map.put(Utils.RESULT, Utils.RESULT_RC_EXCEPTION);
			map.put(Utils.MESSAGE, "获取支付凭证异常！");
		}
		return map;
	}

	/**
	 * Ping++ 支付回调方法
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@Transactional
	@RequestMapping(value = "pingppChargeCallBack")
	public void pingppChargeCallBack(HttpServletRequest request, HttpServletResponse response) throws Exception {
		System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<< 进入支付回调方法 >>>>>>>>>>>>>>>>>>>>>>>");
		Map<String, Object> map = new HashMap<String, Object>();
		try {

			request.setCharacterEncoding("UTF8");
			// 获取头部所有信息
			Enumeration headerNames = request.getHeaderNames();
			while (headerNames.hasMoreElements()) {
				String key = (String) headerNames.nextElement();
				String value = request.getHeader(key);
				System.out.println(key + " " + value);
			}
			// 获得 http body 内容
			BufferedReader reader = request.getReader();
			StringBuffer buffer = new StringBuffer();
			String string;
			while ((string = reader.readLine()) != null) {
				buffer.append(string);
			}
			reader.close();
			logger.error("buffer.toString():" + buffer.toString());
			System.out.println("=============buffer.toString():" + buffer.toString());
			// 解析异步通知数据
			Event event = Webhooks.eventParse(buffer.toString());
			System.out.println(
					"<<<<<<<<<<<<<<<<<<<<<<<<<< pingppChargeCallBack >>>>>>>>>>>>>>>>>>>>>>>" + event.getType());

			if ("charge.succeeded".equals(event.getType())) {
				// System.out.println(event);
				// {
				// "id": "evt_lqVSy5gbL0A68pS8YKvJzdWZ",
				// "created": 1430915345,
				// "livemode": true,
				// "object": "event",
				// "data": {
				// "object": {
				// "id": "ch_ebT0y9iPGCKCL0aPy9X1WLmT",
				// "object": "charge",
				// "created": 1430915284,
				// "livemode": true,
				// "paid": true,
				// "refunded": false,
				// "app": "app_Xz9iXLn9ebX1SOe1",
				// "channel": "wx",
				// "order_no": "as223af2ds",
				// "client_ip": "127.0.0.1",
				// "amount": 100,
				// "amount_settle": 100,
				// "currency": "cny",
				// "subject": "Your Subject",
				// "body": "Your Body",
				// "extra": [],
				// "time_paid": 1430915344,
				// "time_expire": 1431001684,
				// "time_settle": null,
				// "transaction_no": "1001680021201505060112980000",
				// "refunds": {
				// "object": "list",
				// "url": "/v1/charges/ch_ebT0y9iPGCKCL0aPy9X1WLmT/refunds",
				// "has_more": false,
				// "data": []
				// },
				// "amount_refunded": 0,
				// "failure_code": null,
				// "failure_msg": null,
				// "metadata": [],
				// "credential": [],
				// "description": null
				// }
				// },
				// "pending_webhooks": 0,
				// "type": "charge.succeeded",
				// "request": "iar_0K8m90CCeDK8PabXD00yfTq"
				// }
				JSONObject jsonObject = JSONObject.fromObject(buffer.toString());
				// 获取系统订单编号
				JSONObject data = jsonObject.getJSONObject("data");
				JSONObject object = data.getJSONObject("object");
				// 系统订单号
				String order_no = (String) object.get("order_no");

				// 支付方式
				String channel = (String) object.get("channel").toString();
				// ping++返回的订单号
				String transaction_no = (String) object.get("transaction_no");
				// 支付金额
				Integer amount = (Integer) object.get("amount");
				System.out.println("=================order_no:" + order_no + ",channel:" + channel + ",transaction_no="
						+ transaction_no);
				Map<String, String> params = new HashMap<String, String>();
				params.put("serialflagno", order_no);
				params.put("serial", transaction_no);
				params.put("channel", channel);
				params.put("amount", amount + "");

				apiPaymentService.payStatusWriteBack(params, map);
				response.setStatus(200);
			} else if ("refund.succeeded".equals(event.getType())) {
				response.setStatus(500);
			} else {
				response.setStatus(500);
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(Util.getStackTraceAsString(e));
		}
	}

	// // 测试用
	// @RequestMapping(value = "payTest")
	// public void pingppTestjsp(HttpServletRequest request, HttpServletResponse
	// response) throws Exception {
	// String orderno = (String) request.getParameter("orderno");
	// Map<String, Object> map = new HashMap<String, Object>();
	// Map<String, String> params = new HashMap<String, String>();
	// params.put("serialflagno", orderno);
	// params.put("serial", "427395742986592863489264");
	// params.put("channel", "alipay");
	// params.put("amount", 1 + "");
	// apiPaymentService.payStatusWriteBack(params, map);
	// }

}
